<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 竣工资料类型表，对资料进行分类管理
        Schema::create('completion_types', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('project_id')->default(0); // 关联项目 ID
            $table->string('title')->unique(); // 资料类型名称，确保唯一性
            $table->string('content')->nullable()->default('/'); // 资料类型描述，可为空
            $table->timestamps();
        });

        // 竣工资料表，存储资料的基本信息
        Schema::create('completions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('project_id')->default(0); // 关联项目 ID
            $table->unsignedBigInteger('type_id')->default(0); // 关联资料类型 ID
            $table->string('title'); // 资料标题
            $table->string('content')->nullable()->default('/'); // 资料摘要，可为空
            $table->string('files')->nullable()->default('/'); // 资料存储路径，可为空
            $table->string('recipient')->default('/'); // 接收方
            $table->date('delivery_date'); // 交付日期
            $table->string('remark')->nullable()->default('/'); // 交付备注，可为空
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('completion_document_types');
        Schema::dropIfExists('completion_documents');
    }
};
